package com.hzhc.controller.pad;

import com.alibaba.fastjson2.JSONObject;
import com.hzhc.common.BaseController;
import com.hzhc.service.VersionInfoService;
import com.hzhc.utils.ResultUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 功不唐捐
 * @since 2023-09-08
 */
@RestController
@RequestMapping("/ipad/versionInfo")
@RequiredArgsConstructor
public class IpadVersionInfoController extends BaseController {
    @Value("${file.padappAccessPath}")
    private String padappAccessPath;
    private final VersionInfoService versionInfoService;

    /**
     * 判断是否版本更新
     */
    @PostMapping("/judgeVersion")
    public ResultUtil<JSONObject> judgeVersion(@RequestBody String jsonString) {
        JSONObject jsonObject = JSONObject.parseObject(jsonString);
        return versionInfoService.judgeVersion(jsonObject.getString("versionNo"),padappAccessPath);
    }
}
